package com.example.auction.controller;

import com.example.auction.entity.dto.GoodsDTO;
import com.example.auction.entity.vo.GoodsVO;
import com.example.auction.result.Result;
import com.example.auction.service.GoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
@Api(tags = "商品相关接口")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    /*
     * 创建商品接口
     * */
    @PostMapping("/createGoods")
    @ApiOperation("新建商品")
    public Result<String> addGoods(GoodsDTO goodsDTO) {
        goodsService.createGoods(goodsDTO);
        return Result.success("商品新建成功");
    }

    /*
    * 根据用户id查询商品列表
    * */
    @GetMapping("/getGoodsInfo/{id}")
    @ApiOperation("根据用户Id查询商品信息")
    public Result<List<GoodsVO>> getGoodsList(@PathVariable Long id) {
        List<GoodsVO> goodsVOList = goodsService.selectById(id);
        return Result.success(goodsVOList);
    }


}
